/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
*/
package cluster

import (
	"github.com/rs/zerolog/log"
	"github.com/spf13/cobra"
	"satellite/app/cluster"
)

// createCmd represents the createCmd command
var createCmd = &cobra.Command{
	Use:   "create",
	Short: "创建cluster",
	Long:  `创建cluster, 定制创建流程`,
	Args:  Args,
	Run: func(cmd *cobra.Command, args []string) {
		runner := cluster.NewCreate(createOption).WithBase(base)
		err := runner.Run()
		if err != nil {
			log.Warn().Err(err).Send()
			return
		}
	},
}

var (
	createOption = new(cluster.CreateOption)
)

func init() {
	clusterCmd.AddCommand(createCmd)
	createCmd.Flags().BoolVarP(&createOption.Preserving, "preserving", "p", false, "保留实例,如果设置将在现有版本尝试升级")
	createCmd.Flags().StringVarP(&createOption.Version, "version", "v", "8.0", "创建集群版本")
	createCmd.Flags().StringArrayVarP(&createOption.Upgrade, "upgrade", "u", nil, "集群版本升级列表,自动跟踪升级")
}
